<?php

namespace Design\Creational\StaticFactory;

use InvalidArgumentException;

final class StaticFactory
{


    public static function factory(string $type)
    {
        if ($type === 'string') {
            return new StringFormatter();
        } else if ($type === 'number') {
            return new NumberFormatter();
        }

        throw new InvalidArgumentException('Unknown type "'.$type.'" given.');

    }//end factory()


}//end class
